﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using QuanLyKho.QuanLyKho;

namespace QuanLyKho.Control
{
    public partial class Kho_Nhapkho : UserControl
    {
        public Kho_Nhapkho()
        {
            InitializeComponent();
            LoadData();
            SetPropertiesGrid();
        }

        private void LoadData()
        {
            gridNhapkho.DataSource = Data.DataAll.SelectAll("NhapKho_VatTu inner join DkChung_Kho on NhapKho_VatTu.[IDKho] = DkChung_Kho.[IDKho]",
                "DkChung_Kho.[TenKho],NhapKho_VatTu.[ID],NhapKho_VatTu.[TongTien],NhapKho_VatTu.[NgayNhap],NhapKho_VatTu.[NguoiLapPhieu],NhapKho_VatTu.[NguoiChuyen],NhapKho_VatTu.[NgayChungTu],NhapKho_VatTu.[NgayHoachToan],NhapKho_VatTu.[SoChungTu],NhapKho_VatTu.[GhiChu]", "");
            gcID.Visible = false;
        }

        public void SetPropertiesGrid()
        {
            gvNhapkho.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            gvNhapkho.OptionsView.ShowFooter = true;
            gvNhapkho.OptionsFind.AlwaysVisible = true;
            gcID.Visible = false;
        }

        private void bntThemMoi_Click(object sender, EventArgs e)
        {
            Kho_Themnhapkho themnhapkho = new Kho_Themnhapkho();
            themnhapkho.ShowDialog();
            LoadData();
        }

        private void gvNhapkho_DoubleClick(object sender, EventArgs e)
        {
            Kho_Themnhapkho.ID_NhapKho = gvNhapkho.Columns["ID"].View.GetRowCellDisplayText(gvNhapkho.FocusedRowHandle, "ID");
            Kho_Themnhapkho themnhapkho = new Kho_Themnhapkho();
            themnhapkho.ShowDialog();
            LoadData();
            Kho_Themnhapkho.ID_NhapKho = "0";
        }
    }
}
